cmake_minimum_required(VERSION 3.10)

project(IDM VERSION 1.0.0 LANGUAGES CXX)

# 设置C++标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 查找Qt库
find_package(Qt6 REQUIRED COMPONENTS Core Widgets Gui)
find_package(Qt6 COMPONENTS TextToSpeech)

# 设置Qt的moc，但禁用rcc和uic，因为我们没有使用.ui文件
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC OFF)
set(CMAKE_AUTOUIC OFF)

# Windows特定设置
if(WIN32)
    # 设置Windows子系统为Windows GUI (避免控制台窗口)
    set(CMAKE_WIN32_EXECUTABLE ON)
endif()

# 添加可执行文件
add_executable(IDM
    main.cpp
    idm_window.cpp
    idm_window.h
    theme_manager.cpp
    theme_manager.h
    ui_manager.cpp
    ui_manager.h
)

# 链接Qt库
target_link_libraries(IDM 
    Qt6::Core
    Qt6::Widgets
    Qt6::Gui
)

# 如果找到TextToSpeech模块，则链接它
if(Qt6TextToSpeech_FOUND)
    target_link_libraries(IDM Qt6::TextToSpeech)
    target_compile_definitions(IDM PRIVATE HAVE_TEXT_TO_SPEECH)
endif()

# 设置包含目录
target_include_directories(IDM PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

# 设置编译选项
if(MSVC)
    target_compile_options(IDM PRIVATE /W4)
else()
    target_compile_options(IDM PRIVATE -Wall -Wextra)
endif()